package com.szqhyxj.youxiangju.biz.creditCardEvaluation;

import android.text.TextUtils;

import com.szqhyxj.youxiangju.sys.BaseResult;
import com.szqhyxj.youxiangju.sys.RetrofitFacade;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;

/**
 * Created by leung on 2018/11/3.
 */

public class CreaditCardEcaluationModel {
    private interface CreaditCradEcaluationService {
        @FormUrlEncoded
        @POST("creditcard/evaluation/smsAuthorization")
        Observable<BaseResult> sms(
                @Field("cardId") String cardId
        );

        @FormUrlEncoded
        @POST("creditcard/evaluation/smsAuthorizationCheck")
        Observable<BaseResult> smsAuthorizationCheck(
                @Field("validCode") String validCode
        );
    }

    public static Observable<BaseResult> getsms(CreaditCardEcaluationEntity creaditCardEcaluationEntity) {
        return RetrofitFacade.Companion.getRetrofit().create(CreaditCradEcaluationService.class)
                .sms(creaditCardEcaluationEntity.getCardId());
    }

    public static Observable<BaseResult> getsmsAuthorizationCheck(String sms){
        return RetrofitFacade.Companion.getRetrofit().create(CreaditCradEcaluationService.class)
                .smsAuthorizationCheck(sms);
    }



    /**
     * Created by leung on 2018/11/3.
     */

    public static class CreaditCardEcaluationEntity {
        private String cardId;
        private String phone;

        private String referralCode;
        private boolean agree;

        public String getReferralCode() {
            return referralCode;
        }

        public void setReferralCode(String referralCode) {
            this.referralCode = referralCode;
        }

        public boolean isAgree() {
            return agree;
        }

        public void setAgree(boolean agree) {
            this.agree = agree;
        }

        public String getPhone() {
            return phone;
        }

        public void setPhone(String phone) {
            this.phone = phone;
        }


        public String getCardId() {
            return cardId;
        }

        public void setCardId(String cardId) {
            this.cardId = cardId;
        }

        public boolean valid() {
            return !TextUtils.isEmpty(this.phone)
                    && !TextUtils.isEmpty(this.cardId)
                    && !TextUtils.isEmpty(this.referralCode)
                    && this.agree;
        }


    }
}
